#ifndef PLAYER2_H
#define PLAYER2_H

#include <QGraphicsPixmapItem>
#include <QObject>
#include <QKeyEvent>
#include <Qpixmap>
#include<QTimer>
#include"racket.h"

class Player2 :public QObject ,  public QGraphicsPixmapItem
{
    Q_OBJECT
public:
    explicit Player2(QObject *parent1 = nullptr,QGraphicsItem *parent = nullptr);// 防止隐式转换
public:
    ~Player2();
public:
    //通过摁键判断火柴人动作
   // void keyPressEvent(QKeyEvent *event);
        //override;
    //void keyReleaseEvent(QKeyEvent *event);
        //override;
    //判断人物碰撞
    //void line(){}//发球前不过线

public slots:
    void move();
    //void swing();
public:
    //移动标志及速度
    bool m_MoveLeftFlag;
    bool m_MoveRightFlag;
    bool m_MoveUpFlag;
    int m_MoveSpeed;//移动速度
    QTimer *m_MoveTimer;//移动定时器
    QTimer *m_JumpTimer;//跳跃定时器
    QTimer *m_RollTimer;//旋转定时器
    double m_JumpSpeed;
    double m_OriginalY;//记录跳跃前的初始位置
    //判断是否已经发球
    bool m_StartFlag;

    Racket *m_Racket; // 球拍对象
    bool m_MoveRollFlag;//旋转信号
    int m_RacketAngle; // 球拍旋转角度
    int m_RacketAngleSpeed; // 球拍旋转速度
    bool Roll1Flag;//球拍旋转前半程
    bool Roll2Flag;//球拍旋转后半程
    bool Played;//是否轮到击球

    //移动及挥拍图像
    QPixmap m_StartPixmap;
    QPixmap m_StartmovePixmap;
    QPixmap m_StartSwingPixmap;
    QPixmap m_NormalPixmap;
    QPixmap m_MovePixmap;
    QPixmap m_SwingPixmap;
};

#endif // PLAYER2_H
